from multiprocessing import Process, Semaphore, current_process
import time

def subworker(s, i):
    s.acquire()
    print(current_process().name + " acquire")
    time.sleep(i)
    print(current_process().name + " release")
    s.release()

if __name__ == "__main__":  
    s = Semaphore(2)
    for i in range(5):
        p = Process(target=subworker, args=(s, i*2))
        p.start()
